<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"><head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<!-- 引入bootstrap的css -->
<link rel="stylesheet" href="../js/bootstrap/bootstrap3/css/bootstrap.css"></link>
<link rel="stylesheet" href="../js/bootstrap/bootstrap3/css/bootstrap.css.map"></link>
<!-- 引入jquery的js  -->
<script type="text/javascript" src="../js/jquery.min.js"></script>
<!-- 引入bootstrap的js -->
<script type="text/javascript" src="../js/bootstrap/bootstrap3/js/bootstrap.js"></script>
<!-- 引入boostrap的表格的css、js -->
<link rel="stylesheet" href="../js/bootstrap/bootstrap-table/bootstrap-table.css"></link>
<script type="text/javascript" src="../js/bootstrap/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript" src="../js/bootstrap/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
<!-- 引入bootbox弹框的js -->
<script type="text/javascript" src="../js/bootstrap/bootstrap-bootbox/bootbox.js"></script>
<!-- 引入bootbox时间 的css -->
<link rel="stylesheet" href="/js/bootstrap/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css"></link>
<!-- 引入bootbox时间 的js -->
<script type="text/javascript" src="/js/bootstrap/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="/js/bootstrap/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<!-- 引入bootbox上传图片 的css -->
<link rel="stylesheet" href="../js/bootstrap/bootstrap-fileinput/css/fileinput.css"></link>
<!-- 引入bootbox上传图片 的js -->
<script type="text/javascript" src="../js/bootstrap/bootstrap-fileinput/js/fileinput.js"></script>
<script type="text/javascript" src="../js/bootstrap/bootstrap-fileinput/js/locales/zh.js"></script>
<!-- 引入bootbox开关 按钮 的css -->
<link rel="stylesheet" href="../js/bootstrap/bootstrap-switch-master/css/bootstrap3/bootstrap-switch.css"></link>


<body>


<img src="../images/fdd380fb2f7f0f1742f9f7c8ae7c5fec7189073.jpeg">

    <span th:text="${movie.movieName}"></span><br>
     <span th:text="${movie.typename}"></span><br>
     <span th:text="${movie.moviestate}"></span>/
     <span th:text="${movie.moviedate}"></span><br>
     <span th:text="${movie.filmSchedule}"></span>中国大陆上映


    <br><br><br>
    <span th:text="${movie.synopsis}"></span><br>


    <button onclick="duanping()" type="button" class="btn btn-danger">我的短评</button>

<table class="table" id="myTable"></table>


</body>



<script>s




    $(function(){
        initBook();
    })

    function initBook(){

        $('#myTable').bootstrapTable({
            toolbar:'#toolbar',//工具栏
            url:'/buy/findDiscuss',//获取数据地址
            pagination:false, //是否展示分页
            pageList:[2, 4, 6, 10],//分页组件
            pageNumber:1,//默认页码
            pageSize:2,//默认每页条数
            sidePagination:'client',//分页方式：client客户端分页，server服务端分页（*
            striped:true,//斑马线
            queryParams:function(){
                var ids=[[${movie.movieId}]];
                return {
                    ids:ids
                };
            },
            columns:[
                {field:"checkbox",checkbox:true},
                {field:"id",title:"ID"},
                {field:"name",title:"评论人"},
                {field:"discussdate",title:"评论时间"},
                {field:"give",title:"点赞数量"},
                {field:"content",title:"评论内容"},
                {field:"tool",title:"操作",formatter:function(value,row,index){

                        var str="";
                        str+="<button onclick='dianzan(\""+row.id+"\","+row.give+")' class='btn btn‐primary glyphicon glyphicon‐se arch' type='button'>点赞</button>";
                        return str;
                    }},
            ]
        })
    }




    var res;
    function createAddContent(url){
        $.ajax({
            url:url,
            async:false,//同步
            success:function(data){
                res = data;
            }
        });
        return res;
    }

    //新增弹框
    function duanping(){
        bootbox.dialog({
            title:'写短评',
            message: createAddContent("/discuss"),
            closeButton: true,
            buttons : {
                "success" : {
                    "label" : "<i class='icon-ok'></i> 保存",
                    "className" : "btn-sm btn-success",
                    "callback" : function() {//回调函数
                        //提交表单
                        $.ajax({
                            url:"/buy/discuss",
                            type:'post',
                            data:$("#addForm").serialize(),//表单序列化
                            success:function(data){
                                //刷新表格
                                $('#myTable').bootstrapTable('refresh');
                            }
                        });
                    }
                },
                "cancel" : {
                    "label" : "<i class='icon-info'></i> 取消",
                    "className" : "btn-sm btn-danger"
                }
            }
        });

    }




    dianzan=function (ids,give) {
        $.ajax({
            url:"/buy/dianzan",
            data:{ids:ids,give:give},
            success:function () {
                $('#myTable').bootstrapTable('refresh');
            }
        })
    }



</script>
</html>